package com.baizhi.action;

import com.alibaba.fastjson.JSON;
import com.baizhi.Question;
import com.baizhi.service.questionService;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

public class QuestionAction {
    private questionService qs;
    private int c;
    public void show(){
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setCharacterEncoding("utf-8");
        try {
            PrintWriter writer = response.getWriter();
            List<Question> questions = qs.selectAll(c);
            String s = JSON.toJSONString(questions);
            writer.print(s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public questionService getQs() {
        return qs;
    }

    public void setQs(questionService qs) {
        this.qs = qs;
    }

    public int getC() {
        return c;
    }

    public void setC(int c) {
        this.c = c;
    }
}
